import axios from 'axios'
axios.defaults.baseURL = 'http://wudao.cqlink.club'
const instance = axios.create({
  timeout: 5000
})

// 添加请求拦截器
instance.interceptors.request.use(
  function (config) {
    return config
  },
  function (error) {
    return Promise.reject(error)
  }
)
// 添加响应拦截器
instance.interceptors.response.use(
  function (response) {
    return response
  },
  function (error) {
    return Promise.reject(error)
  }
)
export function get (url, params) {
  return instance.get(url, {
    params
  })
}
export function post (url, data) {
  return instance.post(url, data, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      Accept: 'application/json'
    }
  })
}
export function del (url) {
  return instance.delete(url)
}
export function put (url, data) {
  return instance.put(url, data)
}
